<template>
    <div class="game">
        <div class="wrapper">
            <img :src="game_info?.cover"
                 alt=""
                 style="width: 120px; flex-shrink: 0">
            <div class="right-box">
                <div class="title">
                    <span>{{ game_info?.name }}</span>
                    <span>{{ game_info?.download_num }}次下载</span>
                </div>
                <div class="desc">
                    {{ game_info?.description }}
                </div>
                <div class="hint">
                    *免費游可能包括應用程式内購買。
                </div>
                <div class="info">
                    <div class="left">
                        <div>
                            <div class="label">
                                适配系统：
                            </div>
                            <div class="con">
                                {{ game_info?.os }}
                            </div>
                        </div>
                        <div>
                            <div class="label">
                                大小：
                            </div>
                            <div class="con">
                                {{ game_info?.size }}
                            </div>
                        </div>
                        <div>
                            <div class="label">
                                类型：
                            </div>
                            <div class="con">
                                <a v-for="item in game_info?.category_name"
                                   href="">
                                    {{ item }}
                                </a>
                            </div>
                        </div>
                        <div>
                            <div class="label">
                                發行商：
                            </div>
                            <div class="con">
                                {{ game_info?.publisher }}
                            </div>
                        </div>
                        <div>
                            <div class="label">
                                發行日期：
                            </div>
                            <div class="con">
                                {{ game_info?.release_date }}
                            </div>
                        </div>
                        <div class="dp">
                            <div>
                                <img src="../../images/praise.webp" alt="">
                                <span>{{ game_info?.like_count }}</span>
                            </div>
                            <div>
                                <img src="../../images/trample.png" alt="">
                                <span>{{ game_info?.unlike_count }}</span>
                            </div>
                        </div>
                    </div>
                    <div class="score">
                        <div>
                            <span>{{ game_info?.like_score }}</span>
                            <span>%</span>
                        </div>
                        <div>喜欢</div>
                    </div>
                </div>
            </div>
        </div>
        <div class="download">
            <nut-button @click="handleDownload"> 立即下载</nut-button>
        </div>
        <div class="imgs">
            <div v-for="(item, index) in game_info?.covers" :key="index">
                <img :src="item" alt="">
            </div>
        </div>
    </div>
</template>

<script setup>
const props = defineProps({
    game_info: {
        type: Object,
        default: () => {}
    }
})

const handleDownload = () => {
    if(props.game_info.download_url){
        window.open(props.game_info.download_url)
    }
}
</script>

<style lang="scss" scoped>
.game {
    background: #3f3f3f;
    padding: 15px 30px;
    height: fit-content;

    .wrapper {
        display: flex;
        justify-content: space-between;
        gap: 10px;

        .right-box {
            overflow: hidden;
            flex: 1;

            .title {
                display: flex;
                align-items: center;
                justify-content: space-between;

                & > span:first-child {
                    font-size: 16px;
                    font-weight: bold;
                    color: #fff;
                }

                & > span:last-child {
                    font-size: 12px;
                    color: #a5a5a5;
                }
            }

            .desc,
            .hint {
                font-size: 12px;
                line-height: 12px;
            }

            .hint {
                margin-top: 10px;
            }

            .info {
                display: flex;
                align-items: end;
                justify-content: space-between;
                font-size: 12px;
                margin-top: 10px;

                .left {
                    width: 100%;
                    & > div {
                        display: flex;
                        align-items: center;

                        .label {
                            font-weight: bold;
                            width: 60px;
                            flex-shrink: 0;
                        }

                        .con {
                            flex: 1;
                            font-size: 12px;
                            display: flex;
                            flex-wrap: wrap;
                            column-gap: 10px;
                            line-height: 14px;
                            //white-space: nowrap;
                        }
                    }

                    .dp {
                        margin-top: 5px;
                        gap: 20px;

                        & > div {
                            display: flex;
                            align-items: center;
                            gap: 4px;

                            img {
                                width: 14px;
                            }
                        }
                    }
                }

                .score {
                    width: 50px;
                    height: 50px;
                    background: url("../../../game-detail/images/score-bg.webp");
                    background-size: 100% 100%;
                    display: flex;
                    flex-direction: column;
                    align-items: center;
                    justify-content: center;
                    line-height: 1em;
                    // gap: 4px;

                    & > div:first-child {
                        display: flex;
                        align-items: start;
                        gap: 2px;
                        margin-top: 3px;

                        & > span:first-child {
                            font-size: 20px;
                            line-height: 18px;
                            font-weight: bold;
                        }
                    }
                }
            }
        }
    }

    .download {
        margin: 15px 0;
        text-align: center;

        .nut-button {
            width: 144px;
            height: 35px;
            background: #eb49a8;
            color: #fff;
            border-color: #eb49a8;
            font-weight: bold;
            font-size: 16px;
        }
    }

    .imgs {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 2px;
        width: 100%;
        overflow: hidden;

        img {
            width: 100%;
        }
    }
}
</style>
